package com.key.web_admin.controller;


import com.key.common.base.RespResult;
import com.key.modules.dto.IndentDTO;
import com.key.modules.entity.OrderForm;
import com.key.modules.service.IndentService;
import com.key.modules.vo.IndentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/indent")
public class IndentController {

    @Autowired
    private IndentService indentService;

    /**
     * 根据条件得到对应条件的订单信息
     * @param indentDTO
     * @return
     */
    @GetMapping("/showIndent")
    public RespResult<IndentVO> showIndent(@RequestBody IndentDTO indentDTO){
        return indentService.showIndentByDTO(indentDTO);
    }
    /**
     * 添加订单
     * @param orderForm
     * @return
     */
    @PostMapping("/addIndent")
    public RespResult addIndent(@RequestBody OrderForm orderForm){
        return indentService.addIndent(orderForm);
    }

    /**
     * 删除订单，可多个
     * @param ids
     * @return
     */
    @PostMapping("/delIndent")
    public RespResult delIndent(@RequestBody Integer[] ids){
        return indentService.delIndent(ids);
    }

    /**
     * 修改订单信息
     * @param orderForm
     * @return
     */
    @PostMapping("/updateIndent")
    public RespResult updateIndent(@RequestBody OrderForm orderForm){
        return indentService.updateIndent(orderForm);
    }

    /**
     * 审核订单
     * @param id
     * @return
     */
    @PostMapping("/processIndent")
    public RespResult processIndent(Integer id) {
        return indentService.processIndent(id);
    }

    /**
     * 作废订单
     * @param id
     * @return
     */
    @PostMapping("/cancelIndent")
    public RespResult cancelIndent(Integer id) {
        return indentService.cancelIndent(id);
    }

    /**
     * 根据id查询订单信息
     * @param id
     * @return
     */
    @GetMapping ("/showIndentById")
    public RespResult showIndentById(Integer id){
        return indentService.showIndentById(id);
    }


    }
